package com.example.cardgame

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class ChangeActivity : AppCompatActivity() {
    @SuppressLint("MissingInflatedId")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_change)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        val save = findViewById<Button>(R.id.save)
        val cname = findViewById<EditText>(R.id.cname)
        val cage = findViewById<EditText>(R.id.cage)
        val csex = findViewById<EditText>(R.id.csex)
        val cnum = findViewById<EditText>(R.id.cnum)

        save.setOnClickListener(){
            val intent = Intent()
            val str = cname.text.toString() + "," + cage.text.toString() + "," + csex.text.toString() + "," + cnum.text.toString()
            intent.putExtra("FIRST_MSG", str.toString())
            setResult(2, intent)
            finish()
        }
    }
}